import pymysql

db = pymysql.connect("localhost","root","root","image_color")

cursor = db.cursor()

sql = "INSERT INTO config(r,g, b, image_url) VALUES (%d, %d, %d, '%s')" %(re[0],re[1],re[2],image_u)

try:
# 执行sql语句
    cursor.execute(sql)
# 提交到数据库执行
    db.commit()
except Exception as e:
    print(e)
    print("出现问题了")
# 如果发生错误则回滚
    db.rollback()